﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Engine.Dtd.Configuration {
    /// <summary>
    /// Provides access to the public identifier and system value of external entity in a configuration file.
    /// </summary>
    public sealed class PublicElement : ConfigurationElement {
        internal PublicElement() { }

        /// <summary>
        /// Creates a new EntityConfigurationElement with public identifier and system value of
        /// external entity.
        /// </summary>
        /// <param name="publicId">A string that contains the public identifier.</param>
        /// <param name="system">A string that contains the system value of external entity.</param>
        public PublicElement(string publicId, string system) {
            Guard.ArgumentNotNullOrWhitespace(publicId, "publicId");
            Guard.ArgumentNotNullOrWhitespace(system, "system");
            PublicId = publicId;
            Url = system;
            }

        /// <summary>
        /// Gets or sets the public identifier.
        /// </summary>
        [ConfigurationProperty("publicId", IsRequired = true, IsKey = true)]
        public string PublicId {
            get { return (string)this["publicId"]; }
            set { this["publicId"] = value; }
            }

        /// <summary>
        /// Gets or sets the URL of external entity.
        /// </summary>
        [ConfigurationProperty("url", IsRequired = true)]
        public string Url {
            get { return (string)this["url"]; }
            set { this["url"] = value; }
            }
        }
    }
